﻿using AnesSystem;
using AnesSystem.Models;
using AnesSystem.Services;
using MongoDB.Bson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;


namespace AnesSystem.ViewModels
{
    public class NoSecheduledListCtrlViewModel : BaseViewModel<NoSecheduledListCtrlViewModel>
    {
        #region Variables

        private IEnumerable<PatientLinkModel> _noScheduledList;
       
        private PatientLinkModel _selectedItem;
        private string _title;
        private string _seach = "";

        #endregion

        #region Constructor
        public NoSecheduledListCtrlViewModel()
        {
            _noScheduledList = new List<PatientLinkModel>();
        }

        #endregion

        #region Properties

        public IEnumerable<PatientLinkModel> NoScheduledList
        {
            get
            {
                return _noScheduledList;
            }

            set
            {
                _noScheduledList = value;
                RaisePropertyChanged("NoScheduledList");
            }
        }

        public string Title
        {
            get
            {
                return _title;
            }

            set
            {
                _title = value;
                RaisePropertyChanged("Title");
            }
        }

        public string Seach
        {
            get
            {
                return _seach;
            }

            set
            {
                _seach = value;
                NoScheduledList.Clear();
                if (string.IsNullOrEmpty(_seach))
                {
                    NoScheduledList = SecheduleMainCtrlViewModel.Instance.AllOperationList.Where(O => O.Application.Detailstatus.Equals(Constants.OR_STATUS_FLAG_APPLIED));
                }
                else
                {
                    NoScheduledList = SecheduleMainCtrlViewModel.Instance.AllOperationList.Where(O => O.Application.Detailstatus.Equals(Constants.OR_STATUS_FLAG_APPLIED) && (O.Patient.Brxm + O.Patient.Ksmc).IsContain(_seach));
                }
            }
        }

        #endregion

        #region Event

        #endregion

        #region Private Methods


        private void Initdata()
        {
            NoScheduledList.Clear();
            NoScheduledList = SecheduleMainCtrlViewModel.Instance.AllOperationList.Where(O => O.Application.Detailstatus.Equals(Constants.OR_STATUS_FLAG_APPLIED));
            InitTitle();
        }

        #endregion

        #region Public/Protected Methods

        public void InitTitle()
        {
            int count = _noScheduledList.Count();
            Title = string.Format("手术申请——未排({0})", count.ToString());
        }

        public override void Refresh()
        {
            Initdata();
        }

        #endregion

        #region EventHandlers

        #endregion

        #region Command

        #endregion


    }
}
